package com.inoneone.youba.mcht.controller;

import com.inoneone.youba.mcht.dto.BaseRsp;
import com.inoneone.youba.mcht.dto.PageRsp;
import com.inoneone.youba.mcht.dto.req.AnnounceDetailReq;
import com.inoneone.youba.mcht.dto.req.AnnounceListReq;
import com.inoneone.youba.mcht.dto.rsp.AnnounceDetailRsp;
import com.inoneone.youba.mcht.dto.rsp.AnnounceListRsp;
import com.inoneone.youba.mcht.service.AnnouncementApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


@RestController
@RequestMapping(value = "/announcement", method = {RequestMethod.POST})
public class AnnouncementController {
	@Autowired
	private AnnouncementApi announcementApi;

    @PostMapping(value = "/announceList")
    @ResponseBody
    public Object announceList(@RequestBody AnnounceListReq announceListReq) {
        //参数检查
        announceListReq.validate();

        //查询
        PageRsp<AnnounceListRsp> pageInfo = announcementApi.queryAnnounceList(announceListReq);

        //返回
        return new BaseRsp(pageInfo);
    }

    @PostMapping(value = "/announceDetail")
    @ResponseBody
    public Object announceDetail(@RequestBody AnnounceDetailReq announceDetailReq) {
        //参数检查

        //查询
        AnnounceDetailRsp announceDetailRsp = announcementApi.queryAnnounceDetail(announceDetailReq);

        //返回
        return new BaseRsp(announceDetailRsp);
    }
}
